﻿using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.Common;

namespace Chenxin.Lib.Business.DAL
{
    public class v_PrintMoneyInfo
    {
        public v_PrintMoneyInfo()
        { }
        public static Chenxin.Lib.Business.Entity.v_PrintMoneyInfo GetModel(Guid BillId)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from v_PrintMoneyInfo ");
            strSql.Append(" where BillId=@BillId ");
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business_Search");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "BillId", DbType.Guid, BillId);
            Chenxin.Lib.Business.Entity.v_PrintMoneyInfo model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                dataReader.Close();
                dataReader.Dispose();
            }
            return model;
        }

        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public static Chenxin.Lib.Business.Entity.v_PrintMoneyInfo ReaderBind(IDataReader dataReader)
        {
            Chenxin.Lib.Business.Entity.v_PrintMoneyInfo model = new Chenxin.Lib.Business.Entity.v_PrintMoneyInfo();
            object ojb;
            ojb = dataReader["BillId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BillId = new Guid(ojb.ToString());
            }
            model.BillCode = dataReader["BillCode"].ToString();
            ojb = dataReader["InOrOut"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.InOrOut = (int)ojb;
            }
            model.IntentionCode = dataReader["IntentionCode"].ToString();
            model.GetedDepart = dataReader["GetedDepart"].ToString();
            model.GetedEmployee = dataReader["GetedEmployee"].ToString();
            model.HouseAddress = dataReader["HouseAddress"].ToString();
            model.CustomerName_Sale = dataReader["CustomerName_Sale"].ToString();
            model.CustomerName_Buy = dataReader["CustomerName_Buy"].ToString();
            ojb = dataReader["GetedMoney"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.GetedMoney = (decimal)ojb;
            }
            model.PayTo = dataReader["PayTo"].ToString();
            return model;
        }
    }
}